package cn.car.config;

import cn.car.interceptor.JwtInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册JWT拦截器
        registry.addInterceptor(jwtInterceptor)
                // 拦截所有请求
                .addPathPatterns("/123/**")
                // 排除不需要拦截的路径（如登录、注册接口）
                .excludePathPatterns(
                        "/api/user/**",
                        "/api/role/**",
                        "/api/permission/**",
                        "/api/vehicleEntryExit/**",
                        "/api/**"
                );
    }
}
